package cn.edu.hbwe.book.dao;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import cn.edu.hbwe.book.entity.Notice;
import cn.edu.hbwe.book.utils.C3P0Util;


public class NoticeDao {
	private static List<Notice> nlist = new ArrayList<Notice>();
	private static QueryRunner run = new QueryRunner(C3P0Util.getDataSource());

	//查询最新添加或修改的一条公告
	public Notice getRecentNotice() throws SQLException {
		String sql = "select * from notice order by n_time desc limit 0,1";
		return run.query(sql, new BeanHandler<Notice>(Notice.class));
	}

}
